package com.igeek.boot3_web_request.boot.controller;

import com.igeek.boot3_web_request.boot.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;

/**
 * @Author: zhiyu
 * @Date:16:19
 * @DESC:
 */
@Controller
public class ModelController {
    @ModelAttribute
    public User addModelAttribute1(){
        return new User("zhangsan","123456");
    }
    @ModelAttribute
    public void addModelAttribute2(Model model){
        model.addAttribute("user2",new User("lisi","123"));
    }
    @GetMapping("/getModel")
    public User testGetModelAttribute(@ModelAttribute(value = "user2") User user){
        return user;
    }
}
